-- @Author: baidwwy
-- @Date:   2018-06-07 03:17:18
-- @Last Modified by:   baidwwy
-- @Last Modified time: 2018-06-18 09:31:17
require("gge函数")
require "lfs"
__R资源 = {}

function getpathes(rootpath, pathes)
    pathes = pathes or {}
    for entry in lfs.dir(rootpath) do
        if entry ~= '.' and entry ~= '..' then
            local path = rootpath .. '\\' .. entry
            local attr = lfs.attributes(path)
            assert(type(attr) == 'table')

            if attr.mode == 'directory' then
                getpathes(path, pathes)
            else
                table.insert(pathes, path)
            end
        end
    end
    return pathes
end
function __R资源:初始化()
    self.路径_UI = {}

    for i,v in ipairs(getpathes('data/ui')) do
        local id = gge.路径_去除扩展名(gge.路径_取文件名(v))
        if self.路径_UI[id] then
            print('ID重复',id,v)
        else
            self.路径_UI[id] = v
        end
    end
    -- 路径 = {}
    -- for i,v in ipairs(getpathes('d:/data/ui')) do
    --     local id = gge.路径_去除扩展名(gge.路径_取文件名(v))
    --     路径[id] = v
    -- end
end


function __R资源:取界面纹理(id)
    id = string.format("%05d", id)
    if not self.路径_UI[id] then
        -- print(路径[id])
        -- os.copyfile(路径[id],路径[id]:gsub('d:/',''))
        -- self.路径_UI[id] = 路径[id]:gsub('d:/','')

        print(self.路径_UI[id])
        error('文件不存在。')
    end
    return require("gge纹理类")(self.路径_UI[id])
end


function __R资源:取界面精灵(id)
    return require("gge精灵类")(__R资源:取界面纹理(id))
end

function __R资源:取头像纹理(id)
    id = string.format("./data/portraits/%s.png", id)

    return require("gge纹理类")(id)
end


function __R资源:取头像精灵(id)
    return require("gge精灵类")(__R资源:取头像纹理(id))
end